package com.twu.biblioteca.model;

public class Book extends Item{
    private String bookName;
    private String author;
    private String publish;

    public Book(String bookName, String author, String publish) {
        this.bookName = bookName;
        this.author = author;
        this.publish = publish;
    }

    public String getAuthor() {
        return author;
    }

    public String getPublish() {
        return publish;
    }

    public String getBookName() {
        return bookName;
    }

    @Override
    public String toString() {
        return String.format("|BOOK: %s  |  AUTHOR: %s  |  PUBLISH: %s  |", bookName, author, publish);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Book book = (Book) o;

        if (author != null ? !author.equals(book.author) : book.author != null) return false;
        if (bookName != null ? !bookName.equals(book.bookName) : book.bookName != null) return false;
        if (publish != null ? !publish.equals(book.publish) : book.publish != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = bookName != null ? bookName.hashCode() : 0;
        result = 31 * result + (author != null ? author.hashCode() : 0);
        result = 31 * result + (publish != null ? publish.hashCode() : 0);
        return result;
    }
}
